package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.SetReadNotifyRequest;
import keeto.com.vn.bms.network.response.SetReadNotifyResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskSetReadNotify extends AbstractTask{
	String Id;
	String AuthKey;
	
	public TaskSetReadNotify(BMSListener listener, IBMSCore core, String id,
			String authKey) {
		super(listener, core);
		this.Id = id;
		this.AuthKey = authKey;
	}


	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		SetReadNotifyRequest request = new SetReadNotifyRequest();
		request.setAuthKey(Authkey);
		request.setId(Id);
		SetReadNotifyResponse response = protocol.sendReadNotify(request);
		for(BMSListener mListener:listener){
			mListener.finishSendReadNotify(response.getReturnCode(),response.getResultMsg());
		} 
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishSendReadNotify(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,null);
		} 
	}


}
